package com.example.mylibrary.cookies

import okhttp3.Cookie
import okhttp3.CookieJar
import okhttp3.HttpUrl


class CookiejarStore : CookieJar {
    val cookieMap = mutableMapOf<String, List<Cookie>>()

    override fun loadForRequest(url: HttpUrl): List<Cookie> {
        val cookieList = cookieMap.get(url.host)
        return cookieList ?: ArrayList()

    }

    override fun saveFromResponse(url: HttpUrl, cookies: List<Cookie>) {
        cookieMap[url.host] = cookies
    }
}